package com.ruoyi.withholdingfees.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.withholdingfees.domain.WithholdingFees;
import com.ruoyi.withholdingfees.service.IWithholdingFeesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 待扣Controller
 * 
 * @author ruoyi
 * @date 2024-03-05
 */
@RestController
@RequestMapping("/withholdingfees/withholdingfees")
public class WithholdingFeesController extends BaseController
{
    @Autowired
    private IWithholdingFeesService withholdingFeesService;

    /**
     * 查询待扣列表
     */
    @PreAuthorize("@ss.hasPermi('withholdingfees:withholdingfees:list')")
    @GetMapping("/list")
    public TableDataInfo list(WithholdingFees withholdingFees)
    {
        startPage();
        List<WithholdingFees> list = withholdingFeesService.selectWithholdingFeesList(withholdingFees);
        return getDataTable(list);
    }

    /**
     * 导出待扣列表
     */
    @PreAuthorize("@ss.hasPermi('withholdingfees:withholdingfees:export')")
    @Log(title = "待扣", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WithholdingFees withholdingFees)
    {
        List<WithholdingFees> list = withholdingFeesService.selectWithholdingFeesList(withholdingFees);
        ExcelUtil<WithholdingFees> util = new ExcelUtil<WithholdingFees>(WithholdingFees.class);
        util.exportExcel(response, list, "待扣数据");
    }

    /**
     * 获取待扣详细信息
     */
    @PreAuthorize("@ss.hasPermi('withholdingfees:withholdingfees:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(withholdingFeesService.selectWithholdingFeesById(id));
    }

    /**
     * 新增待扣
     */
    @PreAuthorize("@ss.hasPermi('withholdingfees:withholdingfees:add')")
    @Log(title = "待扣", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WithholdingFees withholdingFees)
    {
        return toAjax(withholdingFeesService.insertWithholdingFees(withholdingFees));
    }

    /**
     * 修改待扣
     */
    @PreAuthorize("@ss.hasPermi('withholdingfees:withholdingfees:edit')")
    @Log(title = "待扣", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WithholdingFees withholdingFees)
    {
        return toAjax(withholdingFeesService.updateWithholdingFees(withholdingFees));
    }

    /**
     * 删除待扣
     */
    @PreAuthorize("@ss.hasPermi('withholdingfees:withholdingfees:remove')")
    @Log(title = "待扣", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(withholdingFeesService.deleteWithholdingFeesByIds(ids));
    }
}
